/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * gui.java
 *
 * Created on Mar 18, 2011, 12:36:14 PM
 */
package bittorrent;

import java.io.File;
import javax.swing.JFileChooser;

/**
 *
 * @author Pudy
 */
public class gui extends javax.swing.JFrame {

    /** Creates new form gui */
    public gui() {
        initComponents();
        this.setSize(556, 470);
        this.setResizable(false);
        this.setLocation(400, 100);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        DownloadPanel = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        BrowseBtn = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        SharePanel = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jTextField2 = new javax.swing.JTextField();
        BrowseBtn2 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTextArea2 = new javax.swing.JTextArea();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Share FIle");
        getContentPane().setLayout(null);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        jLabel1.setFont(new java.awt.Font("Tempus Sans ITC", 1, 48)); // NOI18N
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("MyTorrentzzz");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 498, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 53, Short.MAX_VALUE)
                .addGap(12, 12, 12))
        );

        getContentPane().add(jPanel1);
        jPanel1.setBounds(10, 11, 530, 70);

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 518, Short.MAX_VALUE)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 17, Short.MAX_VALUE)
        );

        getContentPane().add(jPanel3);
        jPanel3.setBounds(10, 400, 530, 30);

        jTabbedPane1.setToolTipText("null");
        jTabbedPane1.setAutoscrolls(true);

        DownloadPanel.setLayout(null);

        jLabel2.setText("Open Torrent File");
        DownloadPanel.add(jLabel2);
        jLabel2.setBounds(10, 11, 190, 14);
        DownloadPanel.add(jTextField1);
        jTextField1.setBounds(10, 31, 416, 27);

        BrowseBtn.setText("Browse");
        BrowseBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BrowseBtnActionPerformed(evt);
            }
        });
        DownloadPanel.add(BrowseBtn);
        BrowseBtn.setBounds(432, 33, 84, 23);

        jButton1.setText("Start");
        DownloadPanel.add(jButton1);
        jButton1.setBounds(10, 100, 76, 23);

        jButton2.setText("Pause");
        DownloadPanel.add(jButton2);
        jButton2.setBounds(100, 100, 76, 23);

        jButton3.setText("Stop");
        DownloadPanel.add(jButton3);
        jButton3.setBounds(190, 100, 76, 23);

        jTextArea1.setColumns(20);
        jTextArea1.setRows(5);
        jScrollPane1.setViewportView(jTextArea1);

        DownloadPanel.add(jScrollPane1);
        jScrollPane1.setBounds(10, 130, 500, 150);

        jTabbedPane1.addTab("Download File", DownloadPanel);

        jLabel3.setText("Open File");

        BrowseBtn2.setText("Browse");
        BrowseBtn2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BrowseBtn2ActionPerformed(evt);
            }
        });

        jButton4.setText("Share File");

        jTextArea2.setColumns(20);
        jTextArea2.setRows(5);
        jScrollPane2.setViewportView(jTextArea2);

        javax.swing.GroupLayout SharePanelLayout = new javax.swing.GroupLayout(SharePanel);
        SharePanel.setLayout(SharePanelLayout);
        SharePanelLayout.setHorizontalGroup(
            SharePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(SharePanelLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(SharePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, SharePanelLayout.createSequentialGroup()
                        .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 416, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(BrowseBtn2, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, SharePanelLayout.createSequentialGroup()
                        .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(325, 325, 325))))
            .addGroup(SharePanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(SharePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 500, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(16, Short.MAX_VALUE))
        );
        SharePanelLayout.setVerticalGroup(
            SharePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(SharePanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(SharePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(BrowseBtn2))
                .addGap(33, 33, 33)
                .addComponent(jButton4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 7, Short.MAX_VALUE)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Share File", SharePanel);

        getContentPane().add(jTabbedPane1);
        jTabbedPane1.setBounds(10, 80, 530, 310);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void BrowseBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BrowseBtnActionPerformed
        JFileChooser chooser = new JFileChooser();

        chooser.setMultiSelectionEnabled(true);
        int option = chooser.showOpenDialog(BrowseBtn);
        if (option == JFileChooser.APPROVE_OPTION) {
            File[] sf = chooser.getSelectedFiles();
            String filelist = "";
            if (sf.length > 0) {
                filelist = sf[0].getName();
            }
            for (int i = 1; i < sf.length; i++) {
                filelist += ", " + sf[i].getName();
            }
            jTextField1.setText(filelist);
        }
}//GEN-LAST:event_BrowseBtnActionPerformed

    private void BrowseBtn2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BrowseBtn2ActionPerformed
        JFileChooser chooser = new JFileChooser();

        chooser.setMultiSelectionEnabled(true);
        int option = chooser.showOpenDialog(BrowseBtn2);
        if (option == JFileChooser.APPROVE_OPTION) {
            File[] sf = chooser.getSelectedFiles();
            String filelist = "";
            if (sf.length > 0) {
                filelist = sf[0].getName();
            }
            for (int i=0; i<sf.length; i++) {
                filelist += ", " + sf[i].getName();
            }
            jTextField2.setText(filelist);
        }
    }//GEN-LAST:event_BrowseBtn2ActionPerformed

    /*getContentPane().add(jTabbedPane1);
    JPanel jp1 = new JPanel();
    JPanel jp2 = new JPanel();
    JLabel label1 = new JLabel();
    label1.setText("You are in area of Tab1");
    JLabel label2 = new JLabel();
    label2.setText("You are in area of Tab2");
    jp1.add(label1);
    jp2.add(label2);
    jTabbedPane1.addTab("Tab1", jp1);
    jTabbedPane1.addTab("Tab2", jp2);*/

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new gui().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BrowseBtn;
    private javax.swing.JButton BrowseBtn2;
    private javax.swing.JPanel DownloadPanel;
    private javax.swing.JPanel SharePanel;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JTextArea jTextArea2;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    // End of variables declaration//GEN-END:variables
}
